**********************************************************************************************
* Reproduces Table 6
*
* Ajzenman, Elacqua, Jaimovich and Pérez-Núñez (2024)."Humans versus Chatbots: Scaling-up behavioral interventions to reduce teacher shortages"  	  		
*
**********************************************************************************************



///// Preschool Outcomes 

*Preferences and enrollment in preschool programs. Human and bot effect, main results.
reg preschool_rankfirst i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6a.tex", replace sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean))  nocons

foreach var in preschool_proportion preschool_listed d_enroll_preschool{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6a.tex", append sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean))  nocons
eststo clear
}

*Human vs Bot effect differences p-value	
foreach var in preschool_rankfirst preschool_proportion preschool_listed d_enroll_preschool{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
test 1.grupo_gen=2.grupo_gen	
}

*multiple hypotesis
set seed 40813
rwolf preschool_rankfirst preschool_proportion preschool_listed d_enroll_preschool, indepvar(humano bot) method(reg) controls(education_preference sexo top_30 i.dependencia_colegio) r




///// Primary Outcomes

*Preferences and enrollment in primary programs. Human and bot effect, main results.
reg primary_rankfirst i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6b.tex", replace sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean)) label nocons

foreach var in primary_proportion primary_listed d_enroll_primary{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6b.tex", append sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean)) label nocons
eststo clear
}

*Human vs Bot effect differences p-value
foreach var in primary_rankfirst primary_proportion primary_listed d_enroll_primary{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
test 1.grupo_gen=2.grupo_gen	
}

*multiple hypotesis
rwolf primary_rankfirst primary_proportion primary_listed d_enroll_primary , indepvar(humano bot) method(reg) controls(education_preference sexo top_30 i.dependencia_colegio) r




///// Specialized Outcomes

*Preferences and enrollment in specielized programs. Human and bot effect, main results.

reg specialized_rankfirst i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6c.tex", replace sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean))  nocons

foreach var in specialized_prop specialized_listed d_enroll_specialized{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
estadd ysumm 
outreg2 using "${output}/Table6c.tex", append sdec(4) tex  keep(i.grupo_gen)  addstat(Mean of dependent variable, e(ymean))  nocons
eststo clear
}

*Human vs Bot effect differences p-value
foreach var in specialized_rankfirst specialized_prop specialized_listed d_enroll_specialized{
	
reg `var' i.grupo_gen education_preference sexo i.dependencia_colegio top_30,r
test 1.grupo_gen=2.grupo_gen	
}


*multiple hypotesis
set seed 40813
rename specialized_prop spe_prop
rwolf specialized_rankfirst spe_prop specialized_listed d_enroll_specialized, indepvar(humano bot) method(reg) controls(education_preference sexo top_30 i.dependencia_colegio) r
rename spe_prop specialized_prop


*Note1: The rwolf command does not recognize the variable "specialized_prop," so it had to be renamed for this command. This does not affect the results in any way.

*Note2: Calculations of statistical significance with multiple hypotheses and the significant difference in the bot vs human effect were manually added to the table according to the results produced by the commands run earlier in this code.